package com.glc.gao.gavin.rxjavademo.operator;

import android.view.View;

import com.glc.gao.gavin.rxjavademo.R;

import io.reactivex.Observable;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Predicate;

public class FilterActivity extends BaseActivity {
    @Override
    public int getDescribeText() {
        return R.string.describe_filter;
    }

    @Override
    protected int getContextView() {
        return R.layout.activity_filter;
    }

    public void executeFilter(View view) {
        Observable.just(11, 25, 6, 33, 3, 66).filter(new Predicate<Integer>() {
            @Override
            public boolean test(Integer integer) throws Exception {
                print("integer: " + integer + " , " + (integer > 10));
                return integer > 10;
            }
        }).subscribe(new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) throws Exception {
                print("满足大于10的数字有：" + integer);
            }
        });
    }
}
